package bb.lanxing.lib.devices.bryton.ncs.phone;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;

public class IncomingCallReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).listen(new PhoneStateListener() {
            @Override
            public void onCallStateChanged(int i, String str) {
                super.onCallStateChanged(i, str);
                IncomingCallExtension extension = MessageManager.getInstance().getExtension();
                if (extension != null) {
                    if (1 == i) {
                        extension.addNotification(str, true);
                    } else {
                        extension.addNotification(str, false);
                    }
                }
            }
        }, 32);
        intent.getExtras().getString("incoming_number");
    }
}
